package com.zhiyou100.review.day002.homework;

/**
 * @packageName: Demo1
 * @className: com.zhiyou100.review.day002.demo
 * @Description: TODO day2 练习1
 * @author: yang
 * @date: 2020/6/2
 */
public class HomeWork1 {
    public static void main(String[] args) {
    }

    public static int getOneNumber() {
        int cnt = 0;
        int flag = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 3 == 0 && String.valueOf(i).contains("1")) {
                cnt += i;
                flag++;
            }
        }
        return cnt / flag;
    }

    /**
     * @Description: TODO 获取阶乘
     * @name: getFactorial
     * @param: [into]
     * @return: int
     * @date: 2020/6/2 3:53 下午
     * @auther: yang
     */
    public static int getFactorial(int into) {
        if (into == 0) {
            return 1;
        }
        int max = 1;
        for (int n = 1; n <= into; ++n) {
            max *= n;
        }
        return max;
    }

    /**
     * @Description: TODO  根据年和月份获取本月的天数
     * @name: determineTheNumberOfDaysInAMonth
     * @param: [year, month]
     * @return: int
     * @date: 2020/6/2 3:50 下午
     * @auther: yang
     */
    public static int judgmentDay(int year, int month) {
        int day = 0;
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                day = 31;
                break;
            case 2:
                if (toDetermineLeapYear(year)) {
                    day = 29;
                } else {
                    day = 28;
                }
                break;
            default:
                day = 30;
        }
        return day;
    }

    /**
     * @Description: TODO 判断是不是闰年
     * @name: toDetermineLeapYear
     * @param: [year]
     * @return: void
     * @date: 2020/6/2 3:41 下午
     * @auther: yang
     */
    public static boolean toDetermineLeapYear(int year) {
        //公元年分除以4可整除但除以100不可整除，为闰年。 公元年分除以400可整除，为闰年。
        // 返回true是闰年，false是平年
        return (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));
    }

    /**
     * @Description: TODO  根据性别和年龄获取称呼
     * @name: accessToCall
     * @param: [gender, age]
     * @return: void
     * @date: 2020/6/2 3:15 下午
     * @auther: yang
     */

    public static void accessToCall(char gender, int age) {
        if (gender == '男') {
            if (age >= 0 && age <= 12) {
                System.out.println("小男孩");
            } else if (age > 12 && age <= 30) {
                System.out.println("帅哥");
            } else if (age > 30 && age <= 60) {
                System.out.println("阿姨");
            } else if (age > 60 && age < 120) {
                System.out.println("奶奶");
            } else {
                System.out.println("请输入正确的年龄");
            }

        } else if (gender == '女') {
            if (age >= 0 && age <= 12) {
                System.out.println("小女孩");
            } else if (age > 12 && age <= 30) {
                System.out.println("美女");
            } else if (age > 30 && age <= 60) {
                System.out.println("阿姨");
            } else if (age > 60 && age < 120) {
                System.out.println("奶奶");
            } else {
                System.out.println("请输入正确的年龄");
            }
        } else {
            System.out.println("请输出正确的性别");
        }
    }
}
